package leetcode.weekly.week293;

import java.util.Arrays;

//Solution2Test
public class Solution2 {

	public int maxConsecutive(int bottom, int top, int[] special) {
		int ans = Integer.MIN_VALUE;
		Arrays.sort(special);
		int len = special.length;
		ans = Math.max(special[0] - bottom, top - special[len - 1]);
		int last = special[0];
		for (int i = 1; i < len; i++) {
			int s = special[i];
			ans = Math.max(ans, s - last - 1);
			last = s;
		}
		return ans;
	}

}
